#ifndef ORDERINGPANEL_H
#define ORDERINGPANEL_H

#include <QWidget>
#include <QMap> // For storing cart items

// Forward declarations
class QScrollArea;
class QVBoxLayout; // Or QGridLayout
class QPushButton;
class DarkFoodCard; // Assuming this is the class for product cards
class ShoppingCartDialog;
struct DrinkNode; // From backend/drink.h

class OrderingPanel : public QWidget
{
    Q_OBJECT

public:
    explicit OrderingPanel(int userId, QWidget *parent = nullptr); // Pass user ID
    ~OrderingPanel();

private slots:
    void loadProducts();
    void handleAddToCart(int drinkId, int quantity); // Slot to receive signal from DarkFoodCard
    void openShoppingCart();

private:
    void setupUi();
    void clearProductLayout(); // Helper to remove old cards

    int m_userId; // Store the logged-in user's ID

    QScrollArea *scrollArea;
    QWidget *scrollWidget; // Widget inside scroll area
    QVBoxLayout *productLayout; // Layout for product cards inside scrollWidget
    QPushButton *refreshButton;
    QPushButton *viewCartButton;

    QMap<int, int> m_cartItems; // Key: drinkId, Value: quantity

    DrinkNode* m_drinkListHead = nullptr; // Cache loaded drinks temporarily

    // Potentially a pointer to the shopping cart dialog if needed
    // ShoppingCartDialog* m_cartDialog = nullptr;
};

#endif // ORDERINGPANEL_H